<template>
  <div v-html="form">{{ form }}  {{ this.traceNo }}</div>

</template>

<script>
import axios from 'axios'
import router from '@/router'
export default {
    name:"pay",
    data() {
        return {
            form:"",
            traceNo:this.$route.query.traceNo,
            subject:this.$route.query.subject,
            totalAmount:this.$route.query.totalAmount
        }
    },
    created(){
        this.init()
    },
    methods: {
        init(){
            axios.get("/alipay/pay",{
                traceNo:this.traceNo,
                subject: this.subject,
                totalAmount:this.totalAmount}).then(res=>{
                this.form=res.data;
                const div = document.createElement("divform");
                div.innerHTML = this.form;
                document.body.appendChild(div);
                document.forms[0].acceptCharset = "UTF-8"; // 保持与支付宝默认编码格式一致，如果不一致将会出现：调试错误，请回到请求来源地，重新发起请求，错误代码 invalid-signature 错误原因: 验签出错，建议检查签名字符串或签名私钥与应用公钥是否匹配
                document.forms[0].submit();
                })
        }
    },
}
</script>

<style>

</style>